package com.emm.yixun.marketing.service.impl;

import com.emm.yixun.basic.service.DailySellReportService;
import com.emm.yixun.basic.service.ProjectService;
import com.emm.yixun.basic.service.SaleReturnPmoService;
import com.emm.yixun.common.model.Project;
import com.emm.yixun.common.model.ProjectList;
import com.emm.yixun.common.model.SaleReturnPmo;
import com.emm.yixun.common.model.dailySellDto.*;
import com.emm.yixun.common.model.dto.ProjectDto;
import com.emm.yixun.common.model.dto.SaleReturnPmoDto;
import com.emm.yixun.common.model.enums.ObjectTypeEnum;
import com.emm.yixun.common.model.enums.SaleReturnEnum;
import com.emm.yixun.marketing.service.DailySellReportServiceFacade;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.jws.WebService;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service("dailySellReportServiceFacade")
@WebService(name="com.emm.yixun.marketing.service.DailySellReportServiceFacade")
public class DailySellReportServiceFacadeImpl implements DailySellReportServiceFacade{

	private  final Logger logger = LoggerFactory.getLogger(this.getClass());

	@Autowired
	private DailySellReportService dailySellReportService;
	@Autowired
	private SaleReturnPmoService saleReturnPmoService;
	@Autowired
	private ProjectService projectService;

	@Override
	public List<SubscribeReportDto> getSubscribeReport(DailySellReportRequestDto reqDto) {
		return dailySellReportService.getSubscribeReport(reqDto);
	}

	@Override
	public List<SignedReportDto> getSignedReport(DailySellReportRequestDto reqDto) {
		return dailySellReportService.getSignedReport(reqDto);
	}

	@Override
	public List<ReceivedReportDto> getReceivedReport(DailySellReportRequestDto reqDto) {
		return dailySellReportService.getReceivedReport(reqDto);
	}

	@Override
	public List<CallReportDto> getCallReport(DailySellReportRequestDto reqDto) {
		return dailySellReportService.getCallReport(reqDto);
	}

	@Override
	public List<VisitReportDto> getVisitReport(DailySellReportRequestDto reqDto) {
		return dailySellReportService.getVisitReport(reqDto);
	}

	@Override
	public List<OldVisitReportDto> getOldVisitReport(DailySellReportRequestDto reqDto) {
		return dailySellReportService.getOldVisitReport(reqDto);
	}

	@Override
	public List<DailySellReportResponseDto> getDailySellReportResponse(DailySellReportRequestDto reqDto) {
		List<DailySellReportResponseDto> resDtoList = new ArrayList<DailySellReportResponseDto>();

		String year = reqDto.getYear();
		String month = reqDto.getMonth();
		List<String> projectIds = reqDto.getProjectIds();

		List<SubscribeReportDto> subReportDtoList = getSubscribeReport(reqDto);
		Map<String, SubscribeReportDto> subMap = new HashMap<>();
		if(null != subReportDtoList && subReportDtoList.size() > 0){
			for(SubscribeReportDto subDto: subReportDtoList){
				subMap.put(subDto.getProjectId(), subDto);
			}
		}
		//获取项目销售、回款计划,做销售率、回款率计算
		SaleReturnPmoDto saleReturnPmoDto = new SaleReturnPmoDto();
		saleReturnPmoDto.setObjectType(ObjectTypeEnum.PROJECT.getNo());
		saleReturnPmoDto.setSaleYear(reqDto.getYear());
		List<SaleReturnPmo> srpList = saleReturnPmoService.selectListByDto(saleReturnPmoDto);

		List<SignedReportDto> signedReportDtoList = getSignedReport(reqDto);
		signedReportDtoList = calSignedRate(year, month, srpList, signedReportDtoList);
		Map<String, SignedReportDto> signedMap = new HashMap<>();
		if(null != signedReportDtoList && signedReportDtoList.size() > 0){
			for(SignedReportDto signedDto: signedReportDtoList){
				signedMap.put(signedDto.getProjectId(), signedDto);
			}
		}

		List<ReceivedReportDto> receivedReportDtoList = getReceivedReport(reqDto);
		receivedReportDtoList = calReceivedRate(year, month, srpList, receivedReportDtoList);
		Map<String, ReceivedReportDto> receivedMap = new HashMap<>();
		if(null != receivedReportDtoList && receivedReportDtoList.size() > 0){
			for(ReceivedReportDto receivedDto: receivedReportDtoList){
				receivedMap.put(receivedDto.getProjectId(), receivedDto);
			}
		}

		List<CallReportDto> callReportDtoList = getCallReport(reqDto);
		Map<String, CallReportDto> callMap = new HashMap<>();
		if(null != callReportDtoList && callReportDtoList.size() > 0){
			for(CallReportDto callDto: callReportDtoList){
				callMap.put(callDto.getProjectId(), callDto);
			}
		}

		List<VisitReportDto> visitReportDtoList = getVisitReport(reqDto);
		Map<String, VisitReportDto> visitMap = new HashMap<>();
		if(null != visitReportDtoList && visitReportDtoList.size() > 0){
			for(VisitReportDto visitDto: visitReportDtoList){
				visitMap.put(visitDto.getProjectId(), visitDto);
			}
		}

		List<OldVisitReportDto> oldVisitReportDtoList = getOldVisitReport(reqDto);
		Map<String, OldVisitReportDto> oldVisitMap = new HashMap<>();
		if(null != oldVisitReportDtoList && oldVisitReportDtoList.size() > 0){
			for(OldVisitReportDto oldVisitDto: oldVisitReportDtoList){
				oldVisitMap.put(oldVisitDto.getProjectId(), oldVisitDto);
			}
		}

		//循环项目,组装返回数据
		if(null != projectIds && projectIds.size() > 0){
			ProjectDto projectDto = new ProjectDto();
			String ids = "";
			for(int ii=0; ii<projectIds.size(); ii++){
				ids += projectIds.get(ii);
				if(ii != projectIds.size() - 1){
					ids += ",";
				}
			}
			projectDto.setSqlAppend("AND id in (" + ids +")");
			List<Project> projects =  projectService.selectListByDto(projectDto);

			for(String projectId: projectIds){
				DailySellReportResponseDto responseDto = new DailySellReportResponseDto();
				responseDto.setProjectId(projectId);
				if(null != projects && projects.size() > 0){
					for(Project project: projects){
						if(projectId.equals(String.valueOf(project.getId()))){
							responseDto.setProjectName(project.getProjectName());
						}
					}
				}
				responseDto.setSubscribeReportDto(subMap.get(projectId));
				responseDto.setSignedReportDto(signedMap.get(projectId));
				responseDto.setReceivedReportDto(receivedMap.get(projectId));
				responseDto.setCallReportDto(callMap.get(projectId));
				responseDto.setVisitReportDto(visitMap.get(projectId));
				responseDto.setOldVisitReportDto(oldVisitMap.get(projectId));
				resDtoList.add(responseDto);
			}
		}

		return resDtoList;
	}

	@Override
	public List<DailySellReportResponseDto> getWholeSellReportResponse(DailySellReportRequestDto reqDto) {
		List<DailySellReportResponseDto> resDtoList = new ArrayList<DailySellReportResponseDto>();
		DailySellReportResponseDto resDto = new DailySellReportResponseDto();
		String year = reqDto.getYear();
		String month = reqDto.getMonth();
		List<String> projectIds = reqDto.getProjectIds();

		List<SubscribeReportDto> subReportDtoList = getSubscribeReport(reqDto);
		if(null != subReportDtoList && subReportDtoList.size() > 0){
			SubscribeReportDto subscribeReportDto = new SubscribeReportDto();
			BigDecimal subDayAmountTotal = BigDecimal.ZERO;
			BigDecimal subMonthAmountTotal = BigDecimal.ZERO;
			BigDecimal subYearAmountTotal = BigDecimal.ZERO;
			for(SubscribeReportDto subDto: subReportDtoList){
				subDayAmountTotal = subDayAmountTotal.add(subDto.getSubDayAmount()==null ? BigDecimal.ZERO : subDto.getSubDayAmount());
				subMonthAmountTotal = subMonthAmountTotal.add(subDto.getSubMonthAmount()==null ? BigDecimal.ZERO : subDto.getSubMonthAmount());
				subYearAmountTotal = subYearAmountTotal.add(subDto.getSubYearAmount()==null ? BigDecimal.ZERO : subDto.getSubYearAmount());
			}
			subscribeReportDto.setProjectId(null);
			subscribeReportDto.setSubDayAmount(subDayAmountTotal);
			subscribeReportDto.setSubMonthAmount(subMonthAmountTotal);
			subscribeReportDto.setSubYearAmount(subYearAmountTotal);
			resDto.setSubscribeReportDto(subscribeReportDto);
		}
		//获取项目销售、回款计划,做销售率、回款率计算
		SaleReturnPmoDto saleReturnPmoDto = new SaleReturnPmoDto();
		saleReturnPmoDto.setObjectType(ObjectTypeEnum.PROJECT.getNo());
		saleReturnPmoDto.setSaleYear(reqDto.getYear());
		List<SaleReturnPmo> srpList = saleReturnPmoService.selectListByDto(saleReturnPmoDto);

		List<SignedReportDto> signedReportDtoList = getSignedReport(reqDto);
		signedReportDtoList = calSignedRate(year, month, srpList, signedReportDtoList);
		if(null != signedReportDtoList && signedReportDtoList.size() > 0){
			SignedReportDto signedReportDto = new SignedReportDto();
			BigDecimal signDayAmountTotal = BigDecimal.ZERO;
			BigDecimal signDayAmountPlanTotal = BigDecimal.ZERO;
			BigDecimal signDayAmountRateTotal = BigDecimal.ZERO;
			BigDecimal signMonthAmountTotal = BigDecimal.ZERO;
			BigDecimal signMonthAmountPlanTotal = BigDecimal.ZERO;
			BigDecimal signMonthAmountRateTotal = BigDecimal.ZERO;
			BigDecimal signYearAmountTotal = BigDecimal.ZERO;
			BigDecimal signYearAmountPlanTotal = BigDecimal.ZERO;
			BigDecimal signYearAmountRateTotal = BigDecimal.ZERO;

			for(SignedReportDto signedDto: signedReportDtoList){
				signDayAmountTotal = signDayAmountTotal.add(signedDto.getSignDayAmount() == null ? BigDecimal.ZERO: signedDto.getSignDayAmount());

				signMonthAmountTotal = signMonthAmountTotal.add(signedDto.getSignMonthAmount() == null ? BigDecimal.ZERO: signedDto.getSignMonthAmount());
				signMonthAmountPlanTotal = signMonthAmountPlanTotal.add(signedDto.getSignMonthAmountPlan() == null ? BigDecimal.ZERO: signedDto.getSignMonthAmountPlan());
				if(signMonthAmountPlanTotal.compareTo(BigDecimal.ZERO) != 0){
					signMonthAmountRateTotal = signMonthAmountTotal.divide(signMonthAmountPlanTotal, 2, BigDecimal.ROUND_HALF_UP);
				}

				signYearAmountTotal = signYearAmountTotal.add(signedDto.getSignYearAmount() == null ? BigDecimal.ZERO: signedDto.getSignYearAmount());
				signYearAmountPlanTotal = signYearAmountPlanTotal.add(signedDto.getSignYearAmountPlan() == null ? BigDecimal.ZERO: signedDto.getSignYearAmountPlan());
				if(signYearAmountPlanTotal.compareTo(BigDecimal.ZERO) != 0){
					signYearAmountRateTotal = signYearAmountTotal.divide(signYearAmountPlanTotal, 2, BigDecimal.ROUND_HALF_UP);
				}

			}
			signedReportDto.setProjectId(null);
			signedReportDto.setSignDayAmount(signDayAmountTotal);
			signedReportDto.setSignDayAmountPlan(signDayAmountPlanTotal);
			signedReportDto.setSignDayAmountRate(signDayAmountRateTotal);
			signedReportDto.setSignMonthAmount(signMonthAmountTotal);
			signedReportDto.setSignMonthAmountPlan(signMonthAmountPlanTotal);
			signedReportDto.setSignMonthAmountRate(signMonthAmountRateTotal);
			signedReportDto.setSignYearAmount(signYearAmountTotal);
			signedReportDto.setSignYearAmountPlan(signYearAmountPlanTotal);
			signedReportDto.setSignYearAmountRate(signYearAmountRateTotal);
			resDto.setSignedReportDto(signedReportDto);
		}

		List<ReceivedReportDto> receivedReportDtoList = getReceivedReport(reqDto);
		receivedReportDtoList = calReceivedRate(year, month, srpList, receivedReportDtoList);

		if(null != receivedReportDtoList && receivedReportDtoList.size() > 0){
			ReceivedReportDto receivedReportDto = new ReceivedReportDto();
			BigDecimal receiveDayAmountTotal = BigDecimal.ZERO;
			BigDecimal receiveDayAmountPlanTotal = BigDecimal.ZERO;
			BigDecimal receiveDayAmountRateTotal = BigDecimal.ZERO;
			BigDecimal receiveMonthAmountTotal = BigDecimal.ZERO;
			BigDecimal receiveMonthAmountPlanTotal = BigDecimal.ZERO;
			BigDecimal receiveMonthAmountRateTotal = BigDecimal.ZERO;
			BigDecimal receiveYearAmountTotal = BigDecimal.ZERO;
			BigDecimal receiveYearAmountPlanTotal = BigDecimal.ZERO;
			BigDecimal receiveYearAmountRateTotal = BigDecimal.ZERO;

			for(ReceivedReportDto receiveDto: receivedReportDtoList){
				receiveDayAmountTotal = receiveDayAmountTotal.add(receiveDto.getReceiveDayAmount() == null ? BigDecimal.ZERO: receiveDto.getReceiveDayAmount());

				receiveMonthAmountTotal = receiveMonthAmountTotal.add(receiveDto.getReceiveMonthAmount() == null ? BigDecimal.ZERO: receiveDto.getReceiveMonthAmount());
				receiveMonthAmountPlanTotal = receiveMonthAmountPlanTotal.add(receiveDto.getReceiveMonthAmountPlan() == null ? BigDecimal.ZERO: receiveDto.getReceiveMonthAmountPlan());
				if(receiveMonthAmountPlanTotal.compareTo(BigDecimal.ZERO) != 0){
					receiveMonthAmountRateTotal = receiveMonthAmountTotal.divide(receiveMonthAmountPlanTotal, 2, BigDecimal.ROUND_HALF_UP);
				}

				receiveYearAmountTotal = receiveYearAmountTotal.add(receiveDto.getReceiveYearAmount() == null ? BigDecimal.ZERO: receiveDto.getReceiveYearAmount());
				receiveYearAmountPlanTotal = receiveYearAmountPlanTotal.add(receiveDto.getReceiveYearAmountPlan() == null ? BigDecimal.ZERO: receiveDto.getReceiveYearAmountPlan());
				if(receiveYearAmountPlanTotal.compareTo(BigDecimal.ZERO) != 0){
					receiveYearAmountPlanTotal = receiveYearAmountTotal.divide(receiveYearAmountPlanTotal, 2, BigDecimal.ROUND_HALF_UP);
				}

			}
			receivedReportDto.setProjectId(null);
			receivedReportDto.setReceiveDayAmount(receiveDayAmountTotal);
			receivedReportDto.setReceiveDayAmountPlan(receiveDayAmountPlanTotal);
			receivedReportDto.setReceiveDayAmountRate(receiveDayAmountRateTotal);
			receivedReportDto.setReceiveMonthAmount(receiveMonthAmountTotal);
			receivedReportDto.setReceiveMonthAmountPlan(receiveMonthAmountPlanTotal);
			receivedReportDto.setReceiveMonthAmountRate(receiveMonthAmountRateTotal);
			receivedReportDto.setReceiveYearAmount(receiveYearAmountTotal);
			receivedReportDto.setReceiveYearAmountPlan(receiveYearAmountPlanTotal);
			receivedReportDto.setReceiveYearAmountRate(receiveYearAmountRateTotal);
			resDto.setReceivedReportDto(receivedReportDto);
		}

		List<CallReportDto> callReportDtoList = getCallReport(reqDto);
		if(null != callReportDtoList && callReportDtoList.size() > 0){
			CallReportDto callReportDto = new CallReportDto();
			BigDecimal callDayCountTotal = BigDecimal.ZERO;
			BigDecimal callMonthCountTotal = BigDecimal.ZERO;
			BigDecimal callYearCountTotal = BigDecimal.ZERO;
			for(CallReportDto callDto: callReportDtoList){
				callDayCountTotal = callDayCountTotal.add(callDto.getCallDayCount()==null ? BigDecimal.ZERO : callDto.getCallDayCount());
				callMonthCountTotal = callMonthCountTotal.add(callDto.getCallMonthCount()==null ? BigDecimal.ZERO : callDto.getCallMonthCount());
				callYearCountTotal = callYearCountTotal.add(callDto.getCallYearCount()==null ? BigDecimal.ZERO : callDto.getCallYearCount());
			}
			callReportDto.setProjectId(null);
			callReportDto.setCallDayCount(callDayCountTotal);
			callReportDto.setCallMonthCount(callMonthCountTotal);
			callReportDto.setCallYearCount(callYearCountTotal);
			resDto.setCallReportDto(callReportDto);
		}

		List<VisitReportDto> visitReportDtoList = getVisitReport(reqDto);
		if(null != visitReportDtoList && visitReportDtoList.size() > 0){
			VisitReportDto visitReportDto = new VisitReportDto();
			BigDecimal visitDayCountTotal = BigDecimal.ZERO;
			BigDecimal visitMonthCountTotal = BigDecimal.ZERO;
			BigDecimal visitYearCountTotal = BigDecimal.ZERO;
			for(VisitReportDto visitDto: visitReportDtoList){
				visitDayCountTotal = visitDayCountTotal.add(visitDto.getVisitDayCount()==null ? BigDecimal.ZERO : visitDto.getVisitDayCount());
				visitMonthCountTotal = visitMonthCountTotal.add(visitDto.getVisitMonthCount()==null ? BigDecimal.ZERO : visitDto.getVisitMonthCount());
				visitYearCountTotal = visitYearCountTotal.add(visitDto.getVisitYearCount()==null ? BigDecimal.ZERO : visitDto.getVisitYearCount());
			}
			visitReportDto.setProjectId(null);
			visitReportDto.setVisitDayCount(visitDayCountTotal);
			visitReportDto.setVisitMonthCount(visitMonthCountTotal);
			visitReportDto.setVisitYearCount(visitYearCountTotal);
			resDto.setVisitReportDto(visitReportDto);
		}

		List<OldVisitReportDto> oldVisitReportDtoList = getOldVisitReport(reqDto);
		if(null != oldVisitReportDtoList && oldVisitReportDtoList.size() > 0){
			OldVisitReportDto oldVisitReportDto = new OldVisitReportDto();
			BigDecimal oldVisitDayCountTotal = BigDecimal.ZERO;
			BigDecimal oldVisitMonthCountTotal = BigDecimal.ZERO;
			BigDecimal oldVisitYearCountTotal = BigDecimal.ZERO;
			for(OldVisitReportDto oldVisitDto: oldVisitReportDtoList){
				oldVisitDayCountTotal = oldVisitDayCountTotal.add(oldVisitDto.getOldVisitDayCount()==null ? BigDecimal.ZERO : oldVisitDto.getOldVisitDayCount());
				oldVisitMonthCountTotal = oldVisitMonthCountTotal.add(oldVisitDto.getOldVisitMonthCount()==null ? BigDecimal.ZERO : oldVisitDto.getOldVisitMonthCount());
				oldVisitYearCountTotal = oldVisitYearCountTotal.add(oldVisitDto.getOldVisitYearCount()==null ? BigDecimal.ZERO : oldVisitDto.getOldVisitYearCount());
			}
			oldVisitReportDto.setProjectId(null);
			oldVisitReportDto.setOldVisitDayCount(oldVisitDayCountTotal);
			oldVisitReportDto.setOldVisitMonthCount(oldVisitMonthCountTotal);
			oldVisitReportDto.setOldVisitYearCount(oldVisitYearCountTotal);
			resDto.setOldVisitReportDto(oldVisitReportDto);
		}
		resDto.setProjectId(null);
		resDto.setProjectName(null);
		resDtoList.add(resDto);
		return resDtoList;
	}

	/**
	 * 计算销售额与销售计划比例
	 * @param reportYear 年
	 * @param reportMonth 月
	 * @param srpList 销售回款计划
	 * @param signedReportDtoList 销售报表数据
	 * @return
	 */
	public List<SignedReportDto> calSignedRate(String reportYear, String reportMonth, List<SaleReturnPmo> srpList, List<SignedReportDto> signedReportDtoList){
		if(null != signedReportDtoList && signedReportDtoList.size() > 0){
			for(SignedReportDto signedReportDto: signedReportDtoList){
				// 月,年计划金额
				BigDecimal monthTotal = BigDecimal.ZERO;
				BigDecimal yearTotal = BigDecimal.ZERO;
				if(null != srpList && srpList.size() > 0){
					for(SaleReturnPmo srPmo: srpList){
						if(signedReportDto.getProjectId().equals(String.valueOf(srPmo.getObjectId()))){
							//销售类型
							if(SaleReturnEnum.SALE.getNo().equals(srPmo.getSaleReturn())){
								//月相同,记录月合计
								if(reportMonth.equals(srPmo.getSaleMonth())){
									if(StringUtils.isNotBlank(srPmo.getSalePlan())){
										monthTotal = monthTotal.add(new BigDecimal(srPmo.getSalePlan()));
									}
								}
								//年相同,累加年合计
								if(reportYear.equals(srPmo.getSaleYear())){
									if(StringUtils.isNotBlank(srPmo.getSalePlan())){
										yearTotal = yearTotal.add(new BigDecimal(srPmo.getSalePlan()));
									}
								}
							}
						}
					}
				}
				//日统计没有比例
				signedReportDto.setSignDayAmountRate(BigDecimal.ZERO);
				signedReportDto.setSignDayAmountPlan(BigDecimal.ZERO);

				signedReportDto.setSignMonthAmountPlan(monthTotal);
				if(monthTotal.compareTo(BigDecimal.ZERO) == 0 || null == signedReportDto.getSignMonthAmount()){
					signedReportDto.setSignMonthAmountRate(BigDecimal.ZERO);
				}else{
					signedReportDto.setSignMonthAmountRate(signedReportDto.getSignMonthAmount().divide(monthTotal, 2, BigDecimal.ROUND_HALF_UP));
				}
				signedReportDto.setSignYearAmountPlan(yearTotal);
				if(yearTotal.compareTo(BigDecimal.ZERO) == 0 || null == signedReportDto.getSignYearAmount()){
					signedReportDto.setSignYearAmountRate(BigDecimal.ZERO);
				}else{
					signedReportDto.setSignYearAmountRate(signedReportDto.getSignYearAmount().divide(yearTotal, 2, BigDecimal.ROUND_HALF_UP));
				}
			}
		}
		return signedReportDtoList;
	}

	/**
	 * 计算回款额与回款计划比例
	 * @param reportYear 年
	 * @param reportMonth 月
	 * @param srpList 回款计划
	 * @param receivedReportDtoList 回款统计
	 * @return
	 */
	public List<ReceivedReportDto> calReceivedRate(String reportYear, String reportMonth, List<SaleReturnPmo> srpList, List<ReceivedReportDto> receivedReportDtoList){
		if(null != receivedReportDtoList && receivedReportDtoList.size() > 0){
			for(ReceivedReportDto receivedReportDto: receivedReportDtoList){
				// 月,年计划金额
				BigDecimal monthTotal = BigDecimal.ZERO;
				BigDecimal yearTotal = BigDecimal.ZERO;
				if(null != srpList && srpList.size() > 0){
					for(SaleReturnPmo srPmo: srpList){
						if(receivedReportDto.getProjectId().equals(String.valueOf(srPmo.getObjectId()))){
							//回款类型
							if(SaleReturnEnum.RETURN.getNo().equals(srPmo.getSaleReturn())){
								//月相同,记录月合计
								if(reportMonth.equals(srPmo.getSaleMonth())){
									if(StringUtils.isNotBlank(srPmo.getSalePlan())){
										monthTotal = monthTotal.add(new BigDecimal(srPmo.getSalePlan()));
									}
								}
								//年相同,累加年合计
								if(reportYear.equals(srPmo.getSaleYear())){
									if(StringUtils.isNotBlank(srPmo.getSalePlan())){
										yearTotal = yearTotal.add(new BigDecimal(srPmo.getSalePlan()));
									}
								}
							}
						}
					}
				}
				//日回款不统计比例
				receivedReportDto.setReceiveDayAmountPlan(BigDecimal.ZERO);
				receivedReportDto.setReceiveDayAmountRate(BigDecimal.ZERO);

				receivedReportDto.setReceiveMonthAmountPlan(monthTotal);
				if(monthTotal.compareTo(BigDecimal.ZERO) == 0 || null == receivedReportDto.getReceiveMonthAmount()){
					receivedReportDto.setReceiveMonthAmountRate(BigDecimal.ZERO);
				}else{
					receivedReportDto.setReceiveMonthAmountRate(receivedReportDto.getReceiveMonthAmount().divide(monthTotal, 2, BigDecimal.ROUND_HALF_UP));
				}

				receivedReportDto.setReceiveYearAmountPlan(BigDecimal.ZERO);
				if(yearTotal.compareTo(BigDecimal.ZERO) == 0 || null == receivedReportDto.getReceiveYearAmount()){
					receivedReportDto.setReceiveYearAmountRate(BigDecimal.ZERO);
				}else{
					receivedReportDto.setReceiveYearAmountRate(receivedReportDto.getReceiveYearAmount().divide(yearTotal, 2, BigDecimal.ROUND_HALF_UP));
				}
			}
		}
		return receivedReportDtoList;
	}
}
